# -*- encoding: utf-8 -*-  
  
import urllib2  
from weixin.api.common import getAccToken
  
  
def crtMenu():
    access_token=getAccToken()
    print access_token
    posturl = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + access_token  
    print posturl
    menu = '''{
         "button":[
        {    "name":"查询︱下单",
        "sub_button":[
        {
            "type":"view",
            "name":"快件查询",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx781b55f58cd9eaff&redirect_uri=http%3a%2f%2fzto.wuxizto.com%2fquery&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
        },
        {    
                "type":"view",
                "name":"在线下单",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx781b55f58cd9eaff&redirect_uri=http%3a%2f%2fzto.wuxizto.com%2forder%2f&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
        },
        {    
                "type":"view",
                "name":"费用明细",
                "url":"http://zto.wuxizto.com/feelist/"
        }]
        },
        {
            "name":"常用",
            "sub_button":[
            { 
               "type":"view",
                "name":"个人中心",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx781b55f58cd9eaff&redirect_uri=http%3a%2f%2fzto.wuxizto.com%2fmemcenter%2fmemview%2f&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
           },
             {
                "type":"view",
                "name":"员工入口",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx781b55f58cd9eaff&redirect_uri=http%3a%2f%2fzto.wuxizto.com%2fregadmin%2f&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
            }]
        }]
     }'''  
      
    req=urllib2.urlopen(posturl, menu.encode('utf-8'))
    print req.read()  
crtMenu()
